package com.bo.ioc.component;

import com.bo.ioc.model.UserInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
public class UserComponent {
    public void run(){
        System.out.println("User Component...");
    }

    // @Bean:代表将"方法"交给Spring管理(IOC容器)
    @Bean("userInfo1")
    public UserInfo userInfo(){
        // DI(依赖注入)
        return new UserInfo("zhangsan",18);
    }
    @Primary
    @Bean("userInfo2")
    public UserInfo userInfo2(){
        return new UserInfo("lisi",19);
    }
}
